#ifndef __CUSTOMPARSER_H__
#define __CUSTOMPARSER_H__

#include <QObject>
#include <QUrl>
#include "../httpobserver.h"


class HttpHandler;
class ParserObserver;
class QHttpRequestHeader;

class CustomParser : public QObject, public HttpObserver
{

Q_OBJECT
public:
	CustomParser( const QUrl& url, ParserObserver* observer, QObject* parent );
	~CustomParser();

public: // from HttpObserver
	void		handleResponse( QByteArray data );
	void		error( int errCode );
	void		requestFinished( bool error );
	void		httpDone();
	void		progress( int done, int total );
	void		httpResponseHeaderReceived( const QHttpResponseHeader & resp );

	void		setHeader( const QUrl& url );

signals:
	void linkParsed( const QString& url, CustomParser* self );
	void parseErr( int error, CustomParser* self );
	void progress( int progres );

private:
	HttpHandler*		m_http;
	QHttpRequestHeader* m_httpHeader;
	QString				m_response;
	ParserObserver*		m_observer;
	QString				m_cookie;
	bool				m_done;

};

#endif //__CUSTOMPARSER_H__
//eof
